package plus.logic;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.additional.query.impl.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.additional.query.impl.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.additional.update.impl.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.service.additional.update.impl.UpdateChainWrapper;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

public interface LogicBaseService<T>{

	boolean save(T entity);

	boolean saveBatch(Collection<T> entityList);

	boolean saveBatch(Collection<T> entityList, int batchSize);

	boolean saveOrUpdateBatch(Collection<T> entityList);

	boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize);

	boolean removeById(Serializable id);

	boolean removeByMap(Map<String, Object> columnMap);

	boolean remove(Wrapper<T> queryWrapper);

	boolean removeByIds(Collection<? extends Serializable> idList);

	boolean updateById(T entity);

	boolean update(T entity, Wrapper<T> updateWrapper);

	boolean update(Wrapper<T> updateWrapper);

	boolean updateBatchById(Collection<T> entityList);

	boolean updateBatchById(Collection<T> entityList, int batchSize);

	boolean saveOrUpdate(T entity);

	T getById(Serializable id);

	Collection<T> listByIds(Collection<? extends Serializable> idList);

	Collection<T> listByMap(Map<String, Object> columnMap);

	T getOne(Wrapper<T> queryWrapper);

	T getOne(Wrapper<T> queryWrapper, boolean throwEx);

	Map<String, Object> getMap(Wrapper<T> queryWrapper);

	<V> V getObj(Wrapper<T> queryWrapper, Function<? super Object, V> mapper);

	int count(Wrapper<T> queryWrapper);

	int count();

	List<T> list(Wrapper<T> queryWrapper);

	List<T> list();

	IPage<T> page(IPage<T> page, Wrapper<T> queryWrapper);

	IPage<T> page(IPage<T> page);

	List<Map<String, Object>> listMaps(Wrapper<T> queryWrapper);

	List<Map<String, Object>> listMaps();

	List<Object> listObjs();

	<V> List<V> listObjs(Function<? super Object, V> mapper);

	List<Object> listObjs(Wrapper<T> queryWrapper);

	<V> List<V> listObjs(Wrapper<T> queryWrapper, Function<? super Object, V> mapper);

	IPage<Map<String, Object>> pageMaps(IPage<T> page, Wrapper<T> queryWrapper);

	IPage<Map<String, Object>> pageMaps(IPage<T> page);

	LogicBaseDao<T> getLogicBaseDao();

	QueryChainWrapper<T> query();

	LambdaQueryChainWrapper<T> lambdaQuery();

	UpdateChainWrapper<T> update();

	LambdaUpdateChainWrapper<T> lambdaUpdate();

	boolean saveOrUpdate(T entity, Wrapper<T> updateWrapper);

}
